<template>
    <div class="newsinfo-container">
        <h1 class="title">{{ newsinfolist.title }}</h1>
        <p class='subtitle'>
            <span>发表时间:{{ newsinfolist.add_time }}</span>
            <span>点击:{{ newsinfolist.click }}次</span>
        </p>

        <hr>

        <div class="content" v-html="newsinfolist.content"></div>

        <comment-box :id='this.id'></comment-box>
    </div>
</template>

<script>

import { Toast } from 'mint-ui'
import comment from '../subcomponents/comment.vue'

export default {
    data(){
        return{
            id: this.$route.params.id,
            newsinfolist:{}
        }
    },
    created(){
        this.getNewsInfo();
    },
    methods:{
        getNewsInfo(){ 
            // console.log('1')
            this.$http.get('https://www.easy-mock.com/mock/5cf86de19b40a0058b942993/vue-001/newsinfo/'+this.id).then(result => {
                if(result.status === 200){
                    this.newsinfolist = result.body.data;
                }else{
                    Toast('获取商品列表失败')
                }
            })
        }
    },
    components:{
        'comment-box' : comment
    }
}
</script>

<style lang="scss" >
.newsinfo-container{
    padding: 0 4px;
 
    .title{
        text-align: center;
        font-size: 22px;
        margin:10px 0;
        line-height: 30px;
    }

    .subtitle{
        font-size: 15px;
        display: flex;
        justify-content: space-between;
    }
    
    .content{
        font-size: 17px;
        text-indent: 2em;
        img{
            width: 100%;
            height: 100%;
        }
    }
}

</style>
